<template>
  <div>
    <el-form inline @submit.native.prevent>
      <el-form-item>
        <el-input v-model="form.name" placeholder="请输入用户的手机号" @keyup.enter="handleQuery" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" :disabled="disabled" @click="handleQuery">查询用户方案</el-button>
      </el-form-item>
    </el-form>
    <div v-loading="loading">
      <div v-if="!show">
        暂无结果
      </div>
      <div v-if="data.result">
        <Result v-if="show" :data="data" />
      </div>
    </div>
  </div>
</template>

<script>
import { TableMixin } from '../../../components/mixin'
import { zjQuery } from '../../../api/query'

export default {
  components: {
    Result: () => import('../zj-generate/result')
  },
  mixins: [TableMixin],
  data() {
    return {
      form: {
        name: ''
      },
      data: {
        sy_majors: [],
        remark: '',
        academyScores: [],
        intention_major_firsts: [],
        intention_major_seconds: [],
        intention_major_thirds: [],
        subjects: [],
        intention_colleges: [],
        exclude_majors: [],
        exclude_colleges: [],
        predilection: {},
        result: {
          academy: '[]',
          major: '[]',
          balance: '[]',
          user: {}
        }
      },
      loading: false,
      show: false,
      disabled: false
    }
  },
  mounted() {
    // this.getList()
  },
  methods: {
    getList() {
      // this.wrapResourceList(getList, {})
    },
    handleQuery() {
      this.loading = true
      // this.data = {}
      this.show = false
      zjQuery({
        mobile: this.form.name
      }).then(res => {
        console.log(res)
        const data = Object.assign({}, this.data)
        data['result']['major'] = res.result.major
        data['result']['academy'] = res.result.academy
        data['result']['balance'] = res.result.balance
        data['result']['user'] = {
          level: res.condition.target,
          division: res.condition.subject_category,
          sex: res.condition.sex,
          score: res.condition.score,
          precedence: res.condition.precedence,
          province: res.condition.province
        }
        // data['academyScores'] = res.scores
        data['remark'] = res.condition.remark
        // data['intention_colleges'] = res.intention_colleges
        // data['intention_majors'] = res.intention_majors
        data['intention_major_firsts'] = res.intention_major_firsts
        data['intention_major_seconds'] = res.intention_major_seconds
        data['intention_major_thirds'] = res.intention_major_thirds
        data['subjects'] = res.condition.subjects.split('+')
        // data['exclude_colleges'] = res.exclude_colleges
        data['predilection']['area'] = res.condition.area
        // data['predilection']['exclude_area'] = res.condition.except_province.join('、')
        this.data = data
        this.show = true
      }).finally(() => {
        this.loading = false
      })
    }
  }
}
</script>

<style scoped>

</style>
